package redis;

import redis.clients.jedis.Jedis;

import java.util.Set;

public class JedisTestKey {

    public static void main(String[] args) {

        //连接redis
        Jedis jedis = new Jedis("192.168.153.128",6379);

        //连接测试
        String ret = jedis.ping();
        System.out.println(ret);

        //获取key,value
        Set<String> keys = jedis.keys("*");
        for (String key : keys){
            System.out.println(key + " " + jedis.get(key));
        }

        //判断是否存在、转移键值对
        Boolean k2 = jedis.exists("k2");
        Long k21 = jedis.move("k2", 1);

        //选择数据库
        jedis.select(1);
        System.out.println(jedis.keys("*"));


    }

}
